#include <stdio.h>
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <stdlib.h>
#include <iostream>

#include <glm/glm.hpp>
#include "Camera.h"
#include "MyShader.h"
#include "FileUtil.h"
#include "Model.h"

//#include "test/SimpleTestOpenGl.h"
#include "test/TestAdvanceData_4_7.h"
using namespace std;

int main(int argc, char* argv[]) {

	char* debugDir;
	char* projectDir;
	//argv[0] 是当前运行的exe程序的路径
	//首先得到debug路径
	//然后得到项目路径
	if (!(getParentDir(argv[0], &debugDir) && getParentDir(debugDir, &projectDir))) {
		//printf("%s\n", "main() failed, because getParentDir() call failed, cannot get projectDir");
		return -1;
	}

//    practiseDrawWithPerspective12(projectDir);
    TestAdvanceData_4_7 * test = new TestAdvanceData_4_7();
    test->practise(projectDir);

    delete test;
    return 0;
}

// void framebuffer_size_callback(GLFWwindow* window, int width, int height);

// void process_input(GLFWwindow* window);

// int main(int argc, char** argv){
//     std::cout << "hello world of opengl!" << std::endl;

//     glfwInit();
//     glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
//     glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
//     glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
//     #ifdef __APPLE__
//         glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
//     #endif

//     GLFWwindow * window = glfwCreateWindow(800, 600, "HelloWorldOpenGL", NULL, NULL);
//     if(window == NULL) {
//         std::cout << "fail to create window." << std::endl;
//         glfwTerminate();
//         return -1;
//     }

//     glfwMakeContextCurrent(window);

//     if(!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
//         std::cout << "Failed to initialize GLAD" << std::endl;
//         return -1;
//     }

//     glViewport(0,0,800,600);
//     glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);

//     while(!glfwWindowShouldClose(window)) { 
//         process_input(window);
//         glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
//         glClear(GL_COLOR_BUFFER_BIT);

//         //do something

//         glfwSwapBuffers(window);
//         glfwPollEvents();
//     }

//     glfwTerminate();
//     std::cout << "helloWorldOfOpenGl process is done." << std::endl;
//     return 0;
// }

// void framebuffer_size_callback(GLFWwindow* window, int width, int  height) {
//     glViewport(0, 0, width, height);
// }

// void process_input(GLFWwindow* window) {
//     if(glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS){
//         glfwSetWindowShouldClose(window, true);
//     }
// }